package com.mycompany.dewcineplanet.repository;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.mycompany.dewcineplanet.model.Programacion;

public class ProgramacionRepository {

	List<Programacion> list = null;

	public ProgramacionRepository(){
		list = new ArrayList<Programacion>();
		list.add(new Programacion(new Long(1), new Long(1), new Long(1), new Date()));
		list.add(new Programacion(new Long(2), new Long(2), new Long(2), new Date()));
	}

	public List<Programacion> obtenerTodoProgramacion(){
		return list;
	}

	public Programacion obtenerProgramacion(Long programacion){
		if(list != null && list.size() > 0){
			for(int i = 0; i < list.size(); i++){
				Programacion _programacion = list.get(i);
				if(_programacion.getCodigo().equals(programacion)){
					return _programacion;
				}
			}
		}
		return null;
	}

	public List<Programacion> obtenerProgramacionPelicula(Long pelicula){
		List<Programacion> result = null;
		if(list != null && list.size() > 0){
			for(int i = 0; i < list.size(); i++){
				Programacion programacion = list.get(i);
				if(programacion.getPelicula().equals(pelicula)){
					if(result == null) result = new ArrayList<Programacion>();
					result.add(programacion);
				}
			}
		}
		return result;
	}
}
